/*
 * Copyright (c) 2009-2010, Oracle and/or its affiliates. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 *
 * * Neither the name of Oracle nor the names of its contributors
 *   may be used to endorse or promote products derived from this software without
 *   specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <iostream>
#include <string.h>

#include "fx-parser/fxp.h"
#include "biopp/biopp.h"

#include "lav/antiviral_imp.h"
#include "lav/antiviral_selector.h"
#include "lav/antiviral_set.h"
#include "lav/antiviral.h"
#include "lav/aso_exception.h"
#include "lav/data_base.h"
#include "lav/distance_matrix.h"
#include "lav/optimized_container.h"
#include "lav/sequence.h"
#include "lav/sparse_sequence_space_impl.h"


using namespace lav;
using namespace biopp;

int main(int argc, char** argv)
{
//    set_default_matrix(matrix);
    AntiviralSet antiviralSet;
    PseudoNucSequence  nucSeq;
    std::string s;

    load_sequence("init_seq_posta.txt", nucSeq);
    DataBase DB("antivirals_posta.xml");
    DB.get_antivirals(antiviralSet);

    //veo todos los antivirales
    std::cout << " -------Todos los antivirales ------------" << std::endl;
    std::cout << "CANTIDAD >>>> " << antiviralSet.antivirals.size() << std::endl;
    std::cout << s << std::endl << std::endl;

    ResisBasedAntiviral Abacabir;
    ResisBasedAntiviral Didanosine;
    ResisBasedAntiviral Emtricitabine;
    ResisBasedAntiviral Lamivudine;
    ResisBasedAntiviral Stavudine;
    ResisBasedAntiviral Tenofovir;
    ResisBasedAntiviral Zidovudine;
    ResisBasedAntiviral Nevirapine;
    ResisBasedAntiviral Atazanavir;
    ResisBasedAntiviral Darunavir;
    ResisBasedAntiviral Fosamprenavir;
    ResisBasedAntiviral Indinavir;
    ResisBasedAntiviral Lopinavir;
    ResisBasedAntiviral Efavirenz;
    ResisBasedAntiviral Tipranavir;
    ResisBasedAntiviral Saquinavir;
    ResisBasedAntiviral Nelfinavir;
    ResisBasedAntiviral Prueba1;
    ResisBasedAntiviral Prueba2;
    ResisBasedAntiviral Prueba3;

    AVIterator itt(antiviralSet.antivirals);
    while (!itt.end())
    {
        std::string s;
        (*itt)->get_attrib("name", s);
        if (s == "Abacabir")
            Abacabir = (**itt);
        if (s == "Didanosine")
            Didanosine = (**itt);
        if (s == "Emtricitabine")
            Emtricitabine = (**itt);
        if (s == "Lamivudine")
            Lamivudine = (**itt);
        if (s == "Stavudine")
            Stavudine = (**itt);
        if (s == "Tenofovir")
            Tenofovir = (**itt);
        if (s == "Zidovudine")
            Zidovudine = (**itt);
        if (s == "Nevirapine")
            Nevirapine = (**itt);
        if (s == "Atazanavir")
            Atazanavir = (**itt);
        if (s == "Darunavir")
            Darunavir = (**itt);
        if (s == "Fosamprenavir")
            Fosamprenavir = (**itt);
        if (s == "Indinavir")
            Indinavir = (**itt);
        if (s == "Lopinavir")
            Lopinavir = (**itt);
        if (s == "Efavirenz")
            Efavirenz = (**itt);
        if (s == "Tipranavir")
            Tipranavir = (**itt);
        if (s == "Saquinavir")
            Saquinavir = (**itt);
        if (s == "Nelfinavir")
            Nelfinavir = (**itt);
        if (s == "Prueba1")
            Prueba1 = (**itt);
        if (s == "Prueba2")
            Prueba2 = (**itt);
        if (s == "Prueba3")
            Prueba3 = (**itt);

        ++itt;
    }

    AntiviralSet avsSet;
    avsSet.add_antiviral(Zidovudine);
    avsSet.add_antiviral(Tenofovir);
    avsSet.add_antiviral(Efavirenz);

    AvsResistancesList result;
    avsSet.combine_resistances(result);

    for (AvsResistancesList::iterator it = result.begin(); it != result.end(); ++it)
    {
        for (ResisBasedAntiviral::Resistances::iterator itt = it->begin(); itt != it->end(); ++itt)
        {
            std::cout << itt->pos << " - " << itt->aminoacids << "  |  ";

        }
        std::cout << std::endl ;

    }
    std::cout << "TERMINE " << std::endl;
}


